﻿/**
 * 日志输出类
 * 
 * 用来记录当前代码当前执行的文件名以及行号
 * 
 * By Sunix 
 * E-mail:sunix2010@gmail.com
 * qq Group: 184734163
 * Date 2011-06-23 
 * 
 */
package sunix.uitle {
	public class Logger {
		public static const DEBUG_ALL:uint = 0;  //完全调试模式
		public static const DEBUG_SIMPLE:uint = 1;  //简易调试模式
		public static const NORMAL:uint = 2;  //简易调试模式
		public static var model:uint = DEBUG_ALL;
		
		private static const NEW_LINE:String = ' ';
		private static const BLANK_REP:RegExp = new RegExp(/^]\s*/g);
		private static const REP:RegExp = new RegExp(/]\n\t.*]/);
		private static const BLANK:String = "";
		private static const DEBUG:String = "DEBUG: ";

		
		public static function debug(str : String) : void {
			switch(model){
				case DEBUG_ALL:
					var error:Error = new Error();
					var msg:String = error.getStackTrace();
					var info:String = REP.exec(msg);
					var log:String = info.replace(BLANK_REP,BLANK)
					trace(DEBUG + str + NEW_LINE + log);
					break;
				case DEBUG_SIMPLE:
					trace(DEBUG + str);
					break;
				default:
					return;
			}
		}
	}
}
